package org.reborn.demo

import org.reborn.engine.app._
import org.reborn.engine.input._
import org.reborn.engine.input.jinput._
import org.reborn.engine.enums._
import org.reborn.engine.model.mesh._

import org.reborn.engine.render.texture._

import net.java.games.input.{Mouse => JIMouse, Component}

import org.reborn.utils.niobuffer.BufferUtil
import org.reborn.math._


import com.jogamp.opengl.util._
import com.jogamp.opengl.util.awt.TextRenderer
import javax.media.opengl._
import javax.media.opengl.fixedfunc.GLLightingFunc
import javax.media.opengl.glu._
import java.awt._
import java.awt.event._

object ImageTextures {
  def main(args:Array[String]){
	
	println("java.library.path = "+System.getProperty("java.library.path"))
	  
    val options = new GLAppOptions()
    options.title = "Image Textures Test"
    options.fullscreen = false
    options.debugGL = true
    
	new ImageTextures().startApp(options)
  }
}

class ImageTextures extends Textures {

  import GL._
  import GL2GL3._
  import GL2ES2._
	
  override protected def setupTextures(gl:GL){
    import gl._
    
	//The 1D Texture
	glEnable(GL_TEXTURE_1D);
	tex1D = TextureManager.Texture1D(gl,"classpath:textures/ImageTextures/1D.png")
	
	//The 2D Texture
	glEnable(GL_TEXTURE_2D);
    tex2D = TextureManager.Texture2D(gl,"classpath:textures/ImageTextures/catscan/cat-scan-1.png")
	
	//The CubeMap Texture
	glEnable(GL_TEXTURE_CUBE_MAP);
    val cubeMapImages = 
    	Array("classpath:textures/ImageTextures/cm/cm-left.png",
    			"classpath:textures/ImageTextures/cm/cm-right.png",
    			"classpath:textures/ImageTextures/cm/cm-bottom.png",
    			"classpath:textures/ImageTextures/cm/cm-top.png",
    			"classpath:textures/ImageTextures/cm/cm-back.png",
    			"classpath:textures/ImageTextures/cm/cm-front.png")
    texCubeMap = TextureManager.TextureCubeMap(gl,cubeMapImages)
	
	//The 3D Texture
	val tex3DImages = 1 to 16 map("classpath:textures/ImageTextures/catscan/cat-scan-"+_+".png")
    glEnable(GL_TEXTURE_3D);
	tex3D = TextureManager.Texture3D(gl,tex3DImages)
  }
}